<?php
/**
 * +------ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER * ---------+
 * +----------------------------------------------------------------------------+
 * | PHPKiisf - Keep It in Simple Framework										|
 * | Version 1.0																|
 * | Copyright (C) <2013>  Mario Cezzare <mcezzare@gmail.com>					|
 * | Blog: http://mcezzare.blogspot.com.br										|
 * |																			|
 * | This program is part of PHPKiisf, and is free software: you can			|
 * | redistribute it and/or modify it under the terms of the GNU 				|
 * | General Public License as published by										|
 * | the Free Software Foundation, either version 3 of the License, or			|
 * | (at your option) any later version.										|
 * |																			|
 * | This program is distributed in the hope that it will be useful,			|
 * | but WITHOUT ANY WARRANTY; without even the implied warranty of				|
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the				|
 * | GNU General Public License for more details.								|
 * | You should have received a copy of the GNU General Public License			|
 * | along with this program.  If not, see <http://www.gnu.org/licenses/>.		|
 * +----------------------------------------------------------------------------+
 * | Author : <Mario Cezzare Angelicola Chiodi> <mcezzare@gmail.com>			|
 * +----------------------------------------------------------------------------+
 * | Contributors																|
 * |																			|
 * +----------------------------------------------------------------------------+
 *
 */
/**
 * This file is the framework config view
 *
 * @package Templates
 * @access public
 * @since 2013-03-08
 * @author Mario Cezzare <mcezzare@gmail.com>
 */
?>
<?php
require_once sprintf("%s/%s%s", base_template::$public_dir, 'header', INCLUDE_EXTENSION);
require_once sprintf("%s/%s%s", base_template::$public_dir, 'navbar', INCLUDE_EXTENSION);

//just to minify
$global_params = base_template::$global_params;
/**
 * Verifiy if this page is running on test mode
 */
$test_mode = false;
if (is_array($global_params)) {
    if (in_array("test", $global_params[0])) {
	$test_mode = true;
    }
}
//uncomment for debug
//echo __FILE__ . "<br>" ;
//print_r( dispatcher::$_active_route ) ;
//print_r( $global_params ) ;
?>

<div class="container">
    <div class="hero-unit">
	<h1>
	    <img src="<?= base_template::$public_media_dir ?>/img/icon_settings.png"/><?= base_template::$section_name; ?>
	</h1>
	<p>This is the current configuration of PHPKissf.</p>

		<!--<p><a class="btn btn-primary btn-large">Learn more &raquo;</a></p>-->
    </div>
    <div class="container">
	<div data-role="collapsible-set">
	    <?php $div_name = "php_ini"; ?>

	    <h4>Configuration of php.ini</h4>
	    <?php
	    gui_controller::create_button(array(
		"id" => sprintf("bt_view_%s", $div_name),
		"onclick" => "phpkiisf_js.display_box(this,$('#div_$div_name'));",
		"class" => "btn btn-small",
		"value" => "Hide Details &raquo;",
	    ));
	    ?>
	    <div data-collapsed="false" id="<?php printf("div_%s", $div_name); ?>" class="simple_border" style="display: block">
		<p>
		    <?php
		    $array = config::get_config();
		    utils::dump_array($array, array("test" => $test_mode));
		    /* @todo : control this via post */
		    ?>
		</p>
		<?php
		// create link object looking like a button
		$text_button = "Test this configuration";
		if ($test_mode) {
		    $test_db_button = array(
			"id" => "bt_test_db",
			"value" => "Test DB Connection",
			"href" => "/config/db",
			"class" => "btn btn-primary",
		    );
		    gui_controller::create_button($test_db_button);
		    $text_button = "Reload configuration";
		}
		$simple_test_button = array(
		    "id" => sprintf("bt_view_%s", $div_name),
		    "value" => $text_button,
		    "href" => "/config/test",
		);
		gui_controller::create_button($simple_test_button);
		?>

	    </div>
	    <?php $div_name = "globals"; ?>
	    <h4>Globals</h4>
	    <?php
	    gui_controller::create_button(array(
		"id" => sprintf("bt_view_%s", $div_name),
		"onclick" => "phpkiisf_js.display_box(this,$('#div_$div_name'));",
	    ));
	    ?>
	    <div  id="<?php printf("div_%s", $div_name); ?>" class="simple_border" style="display: none;">

		<p>
		    <?php
		    /* System */
		    print_pre($GLOBALS, null, "D");
		    //										echo utils::object_to_string( $GLOBALS ) ;
		    ?>
		</p>
	    </div>
	    <?php $div_name = "autoload"; ?>
	    <h4>Spl_Autoload_Functions</h4>
	    <?php
	    gui_controller::create_button(array(
		"id" => sprintf("bt_view_%s", $div_name),
		"onclick" => "phpkiisf_js.display_box(this,$('#div_$div_name'));",
	    ));
	    ?>
	    <div  id="<?php printf("div_%s", $div_name); ?>" class="simple_border" style="display: none;">
		<p>
		    <?php
		    /* System */
		    print_pre(spl_autoload_functions(), null, "D");
		    ?>
		</p>
	    </div>
	    <?php $div_name = "constants"; ?>
	    <h4>User Defined Constants</h4>
	    <?php
	    gui_controller::create_button(array(
		"id" => sprintf("bt_view_%s", $div_name),
		"onclick" => "phpkiisf_js.display_box(this,$('#div_$div_name'));",
	    ));
	    ?>
	    <div  id="<?php printf("div_%s", $div_name); ?>" class="simple_border" style="display: none;">
		<p>
		    <?php
		    //										print_pre( get_defined_constants( true ) , null , "D" ) ;
		    utils::show_object(get_defined_constants(true));
		    ?>
		</p>
	    </div>
	    <?php $div_name = "functions"; ?>
	    <h4>Defined Functions</h4>
	    <?php
	    gui_controller::create_button(array(
		"id" => sprintf("bt_view_%s", $div_name),
		"onclick" => "phpkiisf_js.display_box(this,$('#div_$div_name'));",
	    ));
	    ?>
	    <div  id="<?php printf("div_%s", $div_name); ?>" class="simple_border" style="display: none;">
		<p>
		    <?php
		    //										print_pre( get_defined_functions() , null , "D" ) ;
		    utils::show_object(get_defined_functions());
		    ?>
		</p>
	    </div>
	</div>
	<div class="span12">

	    <hr>
	    <footer>
		<p>
		    &copy; <a href="<?= FMW_URL_ABOUT; ?>" target="_blank">PHPKissf 2013</a>
		</p>
	    </footer>
	</div>
    </div>
</div>
<!-- /container -->
<?php
require_once sprintf("%s/%s%s", base_template::$public_dir, 'footer', INCLUDE_EXTENSION);
?>
